<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>dom.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">dom.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Testing utilities for editor specific DOM related tests.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_testing_editor_dom.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">testing/editor/dom.js</div>
    </div>
  </div>
<hr/>


   
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>


  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.assertRangeBetweenText"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">assertRangeBetweenText<span class="args">(<span class="arg">before</span>,&nbsp;<span class="arg">after</span>,&nbsp;<span class="arg">range</span>,&nbsp;<span class="arg">opt_stopAt</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Assert that the range is surrounded by the given strings. This is useful
because different browsers can place the range endpoints inside different
nodes even when visually the range looks the same. Also, there may be empty
text nodes in the way (again depending on the browser) making it difficult to
use assertRangeEquals.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">before</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">String that should occur immediately before the start point of the range. If this is the empty string, assert will only succeed if there is no text before the start point of the range.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">after</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">String that should occur immediately after the end point of the range. If this is the empty string, assert will only succeed if there is no text after the end point of the range.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">range</span>
        : <div class="fullType"><span class="type"><a href="class_goog_dom_AbstractRange.html">goog.dom.AbstractRange</a></span></div>
        <div class="entryOverview">The range to be tested.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_stopAt</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to stop searching at (search will be restricted to this node&#39;s subtree).</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line198">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.getNextNonEmptyTextNode"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">getNextNonEmptyTextNode<span class="args">(<span class="arg">node</span>,&nbsp;<span class="arg">opt_stopAt</span>,&nbsp;<span class="arg">opt_skipDescendants</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type">Text</span></div>
      </div>


     <div class="entryOverview">
       Returns the next (in document order) node from the given node that is a
non-empty text node, or null if none is found or opt_stopAt is not an
ancestor of node. Note that if the given node has children, the search will
start from the start tag of the node, meaning all its descendants will be
included in the search, unless opt_skipDescendants is true.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">node</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to start searching from.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_stopAt</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to stop searching at (search will be restricted to this node&#39;s subtree), defaults to the body of the document containing node.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_skipDescendants</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to skip searching the given node&#39;s descentants.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type">Text</span></div>&nbsp;
            The next (in document order) node from the given node that is a non-empty text node, or null if none is found or opt_stopAt is not an ancestor of node.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line68">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">getPreviousNextNonEmptyTextNodeHelper_<span class="args">(<span class="arg">node</span>,&nbsp;<span class="arg">opt_stopAt</span>,&nbsp;<span class="arg">opt_skipDescendants</span>,&nbsp;<span class="arg">opt_isPrevious</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type">Text</span></div>
      </div>


     <div class="entryOverview">
       Helper that returns the previous or next (in document order) node from the
given node that is a non-empty text node, or null if none is found or
opt_stopAt is not an ancestor of node. Note that if the given node has
children, the search will start from the end or start tag of the node
(depending on whether it&#39;s searching for the previous or next node), meaning
all its descendants will be included in the search, unless
opt_skipDescendants is true.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">node</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to start searching from.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_stopAt</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to stop searching at (search will be restricted to this node&#39;s subtree), defaults to the body of the document containing node.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_skipDescendants</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to skip searching the given node&#39;s descentants.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_isPrevious</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to search for the previous non-empty text node instead of the next one.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type">Text</span></div>&nbsp;
            The next (in document order) node from the given node that is a non-empty text node, or null if none is found or opt_stopAt is not an ancestor of node.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line96">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.getPreviousNonEmptyTextNode"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">getPreviousNonEmptyTextNode<span class="args">(<span class="arg">node</span>,&nbsp;<span class="arg">opt_stopAt</span>,&nbsp;<span class="arg">opt_skipDescendants</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type">Text</span></div>
      </div>


     <div class="entryOverview">
       Returns the previous (in document order) node from the given node that is a
non-empty text node, or null if none is found or opt_stopAt is not an
ancestor of node. Note that if the given node has children, the search will
start from the end tag of the node, meaning all its descendants will be
included in the search, unless opt_skipDescendants is true.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">node</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to start searching from.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_stopAt</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to stop searching at (search will be restricted to this node&#39;s subtree), defaults to the body of the document containing node.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_skipDescendants</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to skip searching the given node&#39;s descentants.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type">Text</span></div>&nbsp;
            The previous (in document order) node from the given node that is a non-empty text node, or null if none is found.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line45">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.getRelativeDepth_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">getRelativeDepth_<span class="args">(<span class="arg">node</span>,&nbsp;<span class="arg">parentNode</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
      </div>


     <div class="entryOverview">
       Returns the depth of the given node relative to the given parent node, or -1
if the given node is not a descendant of the given parent node. E.g. if
node == parentNode returns 0, if node.parentNode == parentNode returns 1,
etc.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">node</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node whose depth to get.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">parentNode</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node relative to which the depth should be calculated.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>&nbsp;
            The depth of the given node relative to the given parent node, or -1 if the given node is not a descendant of the given parent node.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line169">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.getTextFollowingRange_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">getTextFollowingRange_<span class="args">(<span class="arg">range</span>,&nbsp;<span class="arg">isBefore</span>,&nbsp;<span class="arg">opt_stopAt</span>)</span>
        </span>
        &#8658; <div class="fullType"><span>?</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
      </div>


     <div class="entryOverview">
       Returns the text that follows the given range, where the term &quot;follows&quot; means
&quot;comes immediately before the start of the range&quot; if isBefore is true, and
&quot;comes immediately after the end of the range&quot; if isBefore is false, or null
if no non-empty text node is found.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">range</span>
        : <div class="fullType"><span class="type"><a href="class_goog_dom_AbstractRange.html">goog.dom.AbstractRange</a></span></div>
        <div class="entryOverview">The range to search from.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">isBefore</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to search before the range instead of after it.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_stopAt</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to stop searching at (search will be restricted to this node&#39;s subtree).</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span>?</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>&nbsp;
            The text that follows the given range, or null if no non-empty text node is found.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line244">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.editor.dom.isNonEmptyTextNode_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.editor.dom.</span><span class="entryName">isNonEmptyTextNode_<span class="args">(<span class="arg">node</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Returns whether the given node is a non-empty text node.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">node</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">Node to be checked.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            Whether the given node is a non-empty text node.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_editor_dom.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>






      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory editor</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="closure/goog" current="testing/editor/dom.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
